<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends DIVB_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/test
	 *	- or -
	 * 		http://example.com/index.php/test/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct()
	{
		parent::__construct();

		//load sth

	}

	protected function _map(){
		//table
		$cols = array('id'=>'#','num'=>'数字','text'=>'字符');
		$table = array('sql'=>'select * from t_add',
					  'sql_count'=>'select count(*) from t_add',
					  'cols'=>$cols,
					  'title'=>'TEST_TABLE',
					  'dos'=>array(array('name'=>'编辑','uri'=>'index.php/test/edit','key'=>'id'))
					  );
		
		return array('table'=>$table);
	}
//	protected function _before(){
//		echo 'before';
//	}

	public function index()
	{
		$this->load->view('welcome_test');
		//$this->load->view('welcome_message');
	}

	public function testModel(){
		echo 'testModel:start<br>';
		//$list = $this->common_model->get_list('t_add');
		$list = $this->common_model->get_list('t_add',NULL,2,2,'id desc');
		print_r($list);
		$count = $this->common_model->get_count('t_add',array('id'=>6));
		print_r($count);
		$item = $this->common_model->get_item('t_add',array('id'=>2));
		print_r($item);

		$add = $this->common_model->add('t_add',array('num'=>2,'text'=>'hello text'));
		print_r("add:$add");

		$delete = $this->common_model->delete('t_add',array('id'=>5));
		print_r("delete:$delete");
	}

	public function test(){
		echo 'test';
	}

	public function test_view(){
//		$this->load->view('common/header');
//		$this->load->view('common/navbar');
//		$this->load->view('common/menu');
//		$this->load->view('common/footer');
	}
	
	public function test_table(){
			$this->table();  
	}
	public function test_search(){
		
	}
	public function test_add(){
		
	}
	public function test_edit(){
		
	}
}

/* End of file */
	
